<template>
   <div>
    <MyHeader title="购物车案例" color='red' bgc='bule'></MyHeader>
    <div class="main">
      <MyGoods v-for="item in list" :key="item.id" :good="item"></MyGoods>
    </div>
    <MyFooter :list='list'></MyFooter>
  </div>
</template>

<script>
//引入
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
  data() {
    return {
      list:[]
    }
  },
  //获取数据
  created() {
    this.$axios({
      url:"/api/cart",
    }).then(res => 
    // console.log(res)
    this.list = res.data.list// 把获取来的数据传给list空数组
    )
    .catch(err => console.log(err))
  }
}
</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>